<!-- 我的详情 -->

<template>
  <div class="MyDetail">
    <div class="MyDetail-img">
      <div class="MyDetail-img-detail">
        <img v-if="[1, 3].includes(one.doorType)" src="@screen/assets/img/Monitor/door_open.png" />
        <img v-else src="@screen/assets/img/Monitor/door_close.png" />
      </div>

      <div class="MyDetail-img-btn">
        <BtnDefault mini :primary="one.doorType === 1" @click="toOpen">开门</BtnDefault>
        <BtnDefault mini :primary="one.doorType === 2" @click="toClose">关门</BtnDefault>
        <BtnDefault mini :primary="one.doorType === 3" @click="toOpenForever">常开</BtnDefault>
        <BtnDefault mini :primary="one.doorType === 4" @click="toCloseForever">常关</BtnDefault>
      </div>
    </div>

    <WebShow path="door">
      <ShowText label="设备名称" bind="deviceName" />
      <ShowText label="设备类型" bind="deviceTypeName" />
      <ShowText label="厂商名称" bind="manufacturerName" />
      <ShowText label="设备型号" bind="model" />
      <ShowText :label="`所在${CORE.MAP.REGION}`" bind="areaName" />
    </WebShow>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyDetail',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb('door')],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 点击开门
     */
    toOpen() {
      CORE.merge(this.one, { TIP: '开门', controlType: 2 })
      this.startEdit()
    },

    /**
     * 点击关门
     */
    toClose() {
      CORE.merge(this.one, { TIP: '关门', controlType: 1 })
      this.startEdit()
    },

    /**
     * 点击常开
     */
    toOpenForever() {
      CORE.merge(this.one, { TIP: '常开', controlType: 0 })
      this.startEdit()
    },

    /**
     * 点击常关
     */
    toCloseForever() {
      CORE.merge(this.one, { TIP: '常关', controlType: 3 })
      this.startEdit()
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
